<?php
/**
 * 页面的地址接口
 * @author:wangjingming
 * @date：2017 11 17
 */
use Think\Controller;

class BaseController extends Controller {

    protected $_user = array();

    protected function _initialize()
    {
        $access_token = getParam('access_token', "");
        if ($access_token != "") {

            $cur_user_id = D('UserToken')->getUserIdByAccessToken($access_token);
            if ($cur_user_id > 0) {
                $this->_user = D('User')->getSelfInfo($cur_user_id);
            }
        }

        $action = strtolower(ACTION_NAME);
        if ($this->_user == false && $action != 'index' && $action != 'login') {
            redirect("/index.php?m=home&c=Index&a=index");
        }
    }
}
